package com.hxf.service.user.impl;

import com.hxf.dto.AppUserDto;
import com.hxf.dto.ReturnData;
import com.hxf.dto.UserDto;
import com.hxf.exception.DaoLevelException;
import com.hxf.exception.ServiceException;
import com.hxf.service.base.impl.BaseServiceImpl;
import com.hxf.service.user.AppUserService;

public class AppUserServiceImpl extends BaseServiceImpl implements AppUserService {

	/**
	 *查询注册会员
	 */
	public ReturnData<AppUserDto> findByAppUser(AppUserDto appUserDto, int targetPage, int pageSize) throws ServiceException{
		try{
			return super.daoFacade.getAppUserDao().findByAppUser(appUserDto, targetPage, pageSize);
		}catch(DaoLevelException e){
			throw new ServiceException(e.getMessage(), e);
		}
	}
	
	/**
	 * 审核会员状态
	 */
	public void updateUserStatus(String userIds, Integer status)throws ServiceException{
		try {
			 AppUserDto ud = null;
			 if (!"".equals(userIds) && null != userIds) {
				  String userId [] = userIds.split(",");
				  if (null != userId) {
					  for (int i = 0;i < userId.length; i++) {
						  ud = (AppUserDto)super.daoFacade.getAppUserDao().get(AppUserDto.class, Integer.parseInt(userId[i]));
						  ud.setStatus(status);
						  super.daoFacade.getAppUserDao().update(ud);
					  }
				  }
			 } 
		} catch (DaoLevelException e) {
			throw new ServiceException(e.getMessage(), e);
		}
	}
}
